<?php
session_start();
ini_set("display_errors",1); 
include_once '../config.php';
$usrID=intval($_SESSION['usrID']);
$channelID=intval($_GET['channelID']);
$pdo->exec("insert into online set usrID=$usrID,channelID=$channelID,status=1,time=unix_timestamp() on duplicate key update channelID=$channelID,status=1,time=unix_timestamp()");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../css/font-awesome.css" rel="stylesheet" type="text/css" />
<style>
	*{
	padding:0px;
	margin:0px;
	}
	body{
	position: relative;
	text-align: center;
      color: #333;
	font-family: tahoma, Arial, sans-serif;
	font-size: 13px;
		background:#fff;
		overflow:hidden;
		}
hr{
	width:auto;
	border:1px solid #aaa;
	margin:3px 0px;
}
i{
	color:#ccc;
}
i:hover{
	color:#999;
}
a{
	text-decoration: none;
	color:#333;
}

a:active {
    outline: none;
}
img{
	border:none;
	}

.pple_online > article > a > table {
	width:250px;
	height: auto;
	table-layout:auto;
	border-spacing: 0px;
	border-collapse: collapse;
	text-align:left;
}
.pple_online > article > a > table > tbody > tr{
	border-bottom:1px solid #ccc;
}
.pple_online > article > a >table > tbody > tr:hover{
background:#f0f0f0;
}
.pple_online > article > a >table > tbody > tr > td{
	vertical-align:top;
	padding:5px;
}
.pple_online > article > a> table > tbody > tr > td:first-child{
width:40px;
}
	
	
.clear{
clear:both;
}
</style>
<script type="text/javascript" src="../js/ds_a.js"></script>
<script type="text/javascript" src="../js/pi.js"></script>
<script type="text/javascript" src="../js/drag.js"></script>
<script type="text/javascript">
	addEvent(window,"load",function(){
		thread=ajaxThread();
		if (window.document.readyState=="complete"){
			var timer=[];
			setInterval(function(){//update guys online
				thread(['_online.php?channelID='+<?=$channelID;?>],function(){},function(e){
				getObj('pple_online').innerHTML=e.responseText;
				
				if(timer.length > 0){
					for(var i=0;i<timer.length;i++) clearInterval(timer[i]);
				}
				
				for(var i=0;i<getObj('pple_online').getObjN('a').length;i++){
	        	    timer[i]=setInterval(function(i){//pop up new msg
	            	thread(['trigger.php?recID='+getObj('pple_online').getObjN('a')[i].id.split("_")[0]],function(){},function(e){
	  				if(parseInt(e.responseText) !=0) getObj('pple_online').getObjN('a')[i].click();
	  				},function(){});
	  				},2000,i);
	              }

				
				},function(){});
				},5000);

          
			
			}
		});
</script>
</head>
<body>
<div id='activ'></div>
<div class="pple_online" id="pple_online">
<article>
<?php
foreach($pdo->query("select u.fname,u.lname,u.usrID,(select f.freq from pchatfreq f where f.usrID=$usrID and f.recID=u.usrID) as freq from (usr u join online o on o.usrID) where o.usrID=u.usrID and o.channelID=$channelID and u.usrID != $usrID and (unix_timestamp()-o.time) <=10 order by freq desc") as $fetch){
?>
<a href='javascript:void(0)' id='<?="{$fetch['usrID']}_recID";?>' onclick="window.parent.chatBoxDialog('<?=$fetch['fname']." ".$fetch['lname'];?>',<?=$fetch['usrID'];?>)">
<table>
<tbody>
<tr><td><i class="icon-user icon-2x icon-border"></i></td><td><i class='icon-remove-sign'></i>&nbsp;&nbsp;<?=$fetch['fname']." ".$fetch['lname'];?></td></tr>
</tbody>
</table>
</a>
<?php
}
?>
</article>
</div>
</body>
</html>
